package com.kede.api.order.controller;

import com.kede.api.order.service.ISupplieManageService;
import com.kede.domain.StoreUserOrderDomain;
import com.kede.pojo.PagePO;
import com.kede.pojo.ResHttp;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 订单服务
 *
 * @author 11856
 * @date 2023/06/12
 */
@RestController
@RequestMapping("order/orderSupplie")
public class SupplieController {

    @Resource
    private ISupplieManageService supplieManageService;

    /**
     * 用户创建线下订单到门店
     * 后端计算用户花费的德币数量
     * @param storeUserOrderDomain
     * @return
     */
    @PostMapping("createUserStoreOrder")
    public ResHttp createUserStoreOrder(@Validated @RequestBody StoreUserOrderDomain storeUserOrderDomain){
        return supplieManageService.createUserStoreOrder(storeUserOrderDomain);
    }

    /**
     * 获取用户的线下物资订单
     *
     * @param page   页面
     * @param userId 用户id
     * @return {@link ResHttp}
     */
    @GetMapping("getUserSupplieOrder")
    public ResHttp getUserSupplieOrder(PagePO page,Integer userId){
        return supplieManageService.page(page,userId);
    }


    /**
     * 用户删除物资订单
     * @param orderId
     * @return
     */
    @GetMapping("delUserSupplieOrder")
    public ResHttp delUserSupplieOrder(Integer orderId){
        return supplieManageService.delUserSupplieOrder(orderId);
    }


    @GetMapping("userSuppliePaySucces")
    public ResHttp userSuppliePaySucces(Integer payLogId){
        return supplieManageService.userSuppliePaySucces(payLogId);
    }

}
